﻿using System;
using System.Collections.Generic;
using System.Text;

namespace tjb.Utility.IniReadWrite
{
    class RemoteDefine
    {
    }
    #region action 后续操作信息
    /// <summary>
    /// Action后续操作的附加信息
    /// <para>by tangjingbo at 2009-3-12 12:05</para>
    /// </summary>
    public class AcitonAttach
    {
        /// <summary>
        /// 构造函数
        /// <para>by tangjingbo at 2009-3-12 17:36</para>
        /// </summary>
        public AcitonAttach() { }
        /// <summary>
        /// 构造函数
        /// <para>by tangjingbo at 2009-3-12 17:36</para>
        /// </summary>
        /// <param name="AcitonAttachInfo">The aciton attach info.</param>
        public AcitonAttach(string AcitonAttachInfo)
        {
            AcitonAttach b = ParseUtil.StringToActionAttach(AcitonAttachInfo);
            this.section  = b.Section;
            this._Attaches = b.Attaches;
        }
        private string section = "UNDEF";

        /// <summary>
        /// 后续操作类型
        /// <para>by tangjingbo at 2009-3-12 12:05</para>
        /// </summary>
        /// <value></value>
        public string Section 
        {
            get { return section; }
            set { section = value; }
        }
        private List<AttachItem> _Attaches;

        /// <summary>
        /// 后续操作参数列表
        /// <para>by tangjingbo at 2009-3-12 12:05</para>
        /// </summary>
        /// <value></value>
        public List<AttachItem> Attaches
        {
            get { return _Attaches; }
            set { _Attaches = value; }
        }

        /// <summary>
        /// 获取或设置列表项
        /// 设置时如果改键不存在则添加一个
        /// <para>by tangjingbo at 2009-3-12 12:06</para>
        /// </summary>
        /// <value></value>
        public AttachItem this[string key]
        {
            get
            {
                foreach (AttachItem ai in _Attaches)
                    if (ai.Key == key)
                        return ai;

                return null;
            }
            set
            {
                bool isAdd = true;
                for (int i = _Attaches.Count - 1; i >= 0; i--)
                    if (_Attaches[i].Key == key)
                    {
                        _Attaches[i] = value;
                        isAdd = false;
                    }
                if (isAdd)
                    _Attaches.Add(value);
            }
        }
        /// <summary>
        /// 转换成字符串序列
        /// <para>by tangjingbo at 2009-3-12 17:34</para>
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            return ParseUtil.AttachToString(this);
        }

        /// <summary>
        /// 
        /// <para>by tangjingbo at 2009-3-13 13:53</para>
        /// </summary>
        /// <param name="ﻒ">The ﻒ.</param>
        /// <returns></returns>
        public static implicit operator string(AcitonAttach ﻒ)
        {
            return ParseUtil.AttachToString(ﻒ);
        }

        /// <summary>
        /// 
        /// <para>by tangjingbo at 2009-3-13 13:53</para>
        /// </summary>
        /// <param name="ﻒ">The ﻒ.</param>
        /// <returns></returns>
        public static implicit operator AcitonAttach(string ﻒ)
        {
            return ParseUtil.StringToActionAttach(ﻒ);
        }
    }
    /// <summary>
    /// action操作的后续操作的选择项
    /// <para>by tangjingbo at 2009-3-12 12:05</para>
    /// </summary>
    public class AttachItem
    {
        /// <summary>
        /// 构造函数
        /// <para>by tangjingbo at 2009-3-12 13:07</para>
        /// </summary>
        public AttachItem()
        {
        }

        /// <summary>
        /// 构造函数
        /// <para>by tangjingbo at 2009-3-12 13:07</para>
        /// </summary>
        /// <param name="key">The key.</param>
        /// <param name="value">The value.</param>
        /// <param name="flag">if set to <c>true</c> [flag].</param>
        public AttachItem(string key, string value, bool flag)
        {
            _Key = key;
            _Value = value;
            _Flag = flag;
        }
        private string _Key;

        /// <summary>
        /// 标题
        /// <para>by tangjingbo at 2009-3-10 17:18</para>
        /// </summary>
        /// <value></value>
        public string Key
        {
            get { return _Key; }
            set { _Key = value; }
        }
        private string _Value;

        /// <summary>
        /// 标题对应的值
        /// <para>by tangjingbo at 2009-3-10 17:22</para>
        /// </summary>
        /// <value></value>
        public string Value
        {
            get { return _Value; }
            set { _Value = value; }
        }
        private bool _Flag;

        /// <summary>
        /// 附加标记。 目前有2种附加信息。如果为[Data]处理则用来表示输出参数是否必添；如果为[Route]则用于输入参数时时确定是否选中。
        /// <para>by tangjingbo at 2009-3-10 17:22</para>
        /// </summary>
        /// <value></value>
        public bool Flag
        {
            get { return _Flag; }
            set { _Flag = value; }
        }
    }
    #endregion
}
